package net.flyinggroup.scalar.controller;

import net.flyinggroup.scalar.model.Product;
import net.flyinggroup.scalar.repository.ProductRepository;
import org.springframework.graphql.data.method.annotation.QueryMapping;
import org.springframework.stereotype.Controller;

import java.util.List;

@Controller
public class ProductController {
    private ProductRepository productRepository;

    public ProductController(ProductRepository productRepository) {
        this.productRepository = productRepository;
    }

    @QueryMapping
    public List<Product> allProducts() {
        return productRepository.findAll();
    }
}
